import router from "./router";

import store from "./store";


const whiteList = ['/login', '/404', '/401']

router.beforeEach((to, from, next) => {
    // console.log(store.getters.token);
    if(store.getters.token){
        if(to.path == '/login'){
            next(from.path)
        }else{
            next()
        }
    }else{
        if(whiteList.indexOf(to.path) > -1){
            next();
        }else{
            next('/login')
        }
    }
})